import { ColumnProps } from '~/library/components/ProTable/interface'
import { getSupplierAPI } from '~/src/api/goods'
import { Procure } from '~/src/api/interface/procure'
import { getLastQuarterDays } from '~/src/utils/date'
import { formatDate } from '~/src/utils/date-formatter'

export const warehouseTotalColumns: ColumnProps<Procure.ProcureWarehouseTotalDetail>[] = [
  {
    type: 'index',
    label: '序号',
    width: 60,
    search: {
      el: 'date-picker',
      label: '业务日期',
      key: 'date',
      order: 1,
      defaultValue: [formatDate(-getLastQuarterDays(), 'start', 'yyyy-MM-dd'), formatDate(0, 'end', 'yyyy-MM-dd')],
      props: {
        type: 'datetimerange',
        format: 'YYYY-MM-DD',
        valueFormat: 'YYYY-MM-DD',
      },
    },
  },
  { sortable: true, prop: 'goodsName', label: '商品名称', minWidth: 150 },
  { sortable: true, prop: 'sn', label: '商品代码', minWidth: 120 },
  { sortable: true, prop: 'categoryName', label: '商品分类', minWidth: 150 },
  { sortable: true, prop: 'spesDesc', label: '商品规格', minWidth: 120 },
  { sortable: true, prop: 'unitName', label: '采购单位', minWidth: 160 },
  { sortable: true, prop: 'defaultUnit', label: '基本单位', minWidth: 120 },
  { sortable: true, prop: 'quantity', label: '收货数量', minWidth: 120 },
  { sortable: true, prop: 'giftQuantity', label: '赠品数量', minWidth: 120 },
  // { sortable: true, prop: 'returnQuantity', label: '退货数量', minWidth: 120 },
  // { sortable: true, prop: 'giftReturnQuantity', label: '赠品退货数量', minWidth: 150 },
  { sortable: true, prop: 'basicQuantity', label: '基本数量', minWidth: 120 },
  { sortable: true, prop: 'convert', label: '换算率', minWidth: 120 },
  { sortable: true, prop: 'price', label: '收货单价', minWidth: 120 },
  { sortable: true, prop: 'basePrice', label: '基本单价', minWidth: 120 },
  { sortable: true, prop: 'lastInvoicePrice', label: '最近进价', minWidth: 120 },
  { sortable: true, prop: 'amount', label: '收货金额', minWidth: 120 },
  {
    sortable: true,
    prop: 'supplierName',
    label: '供应商',
    minWidth: 120,
    enum: () => getSupplierAPI({ pageNum: 1, pageSize: 9999 }),
    fieldNames: { label: 'name', value: 'id' },
    isFilterEnum: false,
    search: { el: 'select', key: 'supplierId' },
  },

  { sortable: true, prop: 'orderNo', label: '单据编号', minWidth: 160 },
  { sortable: true, prop: 'date', label: '收货日期', minWidth: 140 },
  { sortable: true, prop: 'createTime', label: '制单时间', minWidth: 164 },
  { sortable: true, prop: 'checkTime', label: '审核时间', minWidth: 164 },
  // {
  //   sortable: true,
  //   prop: 'checkFlagName',
  //   label: '审核状态',
  //   minWidth: 120,
  //   align: 'left',
  // },
  {
    sortable: true,
    prop: 'remark',
    label: '备注',
    align: 'left',
    minWidth: 160,
  },
]
export const rejectionTotalColumns: ColumnProps<Procure.ProcureWarehouseTotalDetail>[] = [
  {
    type: 'index',
    label: '序号',
    width: 60,
    search: {
      el: 'date-picker',
      label: '业务日期',
      key: 'date',
      order: 1,
      defaultValue: [formatDate(-getLastQuarterDays(), 'start', 'yyyy-MM-dd'), formatDate(0, 'end', 'yyyy-MM-dd')],
      props: {
        type: 'datetimerange',
        format: 'YYYY-MM-DD',
        valueFormat: 'YYYY-MM-DD',
      },
    },
  },
  { sortable: true, prop: 'goodsName', label: '商品名称', minWidth: 150 },
  { sortable: true, prop: 'sn', label: '商品代码', minWidth: 120 },
  { sortable: true, prop: 'categoryName', label: '商品分类', minWidth: 150 },
  { sortable: true, prop: 'spesDesc', label: '商品规格', minWidth: 120 },
  { sortable: true, prop: 'unitName', label: '退货单位', minWidth: 160 },
  { sortable: true, prop: 'defaultUnit', label: '基本单位', minWidth: 120 },
  { sortable: true, prop: 'quantity', label: '退货数量', minWidth: 120 },
  { sortable: true, prop: 'giftQuantity', label: '赠品数量', minWidth: 120 },
  // { sortable: true, prop: 'returnQuantity', label: '退货数量', minWidth: 120 },
  // { sortable: true, prop: 'giftReturnQuantity', label: '赠品退货数量', minWidth: 150 },
  { sortable: true, prop: 'basicQuantity', label: '基本数量', minWidth: 120 },
  { sortable: true, prop: 'convert', label: '换算率', minWidth: 120 },
  { sortable: true, prop: 'price', label: '收货单价', minWidth: 120 },
  { sortable: true, prop: 'basePrice', label: '基本单价', minWidth: 120 },
  { sortable: true, prop: 'lastInvoicePrice', label: '最近进价', minWidth: 120 },
  { sortable: true, prop: 'amount', label: '收货金额', minWidth: 120 },
  {
    sortable: true,
    prop: 'supplierName',
    label: '供应商',
    minWidth: 120,
    enum: () => getSupplierAPI({ pageNum: 1, pageSize: 9999 }),
    fieldNames: { label: 'name', value: 'id' },
    isFilterEnum: false,
    search: { el: 'select', key: 'supplierId' },
  },
  { sortable: true, prop: 'orderNo', label: '单据编号', minWidth: 160 },
  { sortable: true, prop: 'date', label: '收货日期', minWidth: 140 },
  { sortable: true, prop: 'createTime', label: '制单时间', minWidth: 164 },
  { sortable: true, prop: 'checkTime', label: '审核时间', minWidth: 164 },
  // {
  //   sortable: true,
  //   prop: 'checkFlagName',
  //   label: '审核状态',
  //   minWidth: 120,
  //   align: 'left',
  // },
  {
    sortable: true,
    prop: 'remark',
    label: '备注',
    align: 'left',
    minWidth: 160,
  },
]
export const goodsTotalColumns: ColumnProps<Procure.ProcureWarehouseTotalDetail>[] = [
  {
    type: 'index',
    label: '序号',
    width: 60,
    search: {
      el: 'date-picker',
      label: '业务日期',
      key: 'date',
      order: 1,
      defaultValue: [formatDate(-getLastQuarterDays(), 'start', 'yyyy-MM-dd'), formatDate(0, 'end', 'yyyy-MM-dd')],
      props: {
        type: 'datetimerange',
        format: 'YYYY-MM-DD',
        valueFormat: 'YYYY-MM-DD',
      },
    },
  },
  { sortable: true, prop: 'sn', label: '商品代码', minWidth: 120 },
  { sortable: true, prop: 'goodsName', label: '商品名称', minWidth: 180 },
  { sortable: true, prop: 'barcode', label: '商品条码', minWidth: 180 },
  { sortable: true, prop: 'deliveryQuantity', label: '收货数量', minWidth: 120 },
  { sortable: true, prop: 'deliveryAmount', label: '收货金额', minWidth: 120 },
  { sortable: true, prop: 'giftDeliveryQuantity', label: '收货赠送数量', minWidth: 150 },
  { sortable: true, prop: 'returnQuantity', label: '退货数量', minWidth: 120 },
  { sortable: true, prop: 'returnAmount', label: '退货金额', minWidth: 120 },
  { sortable: true, prop: 'giftReturnQuantity', label: '退货赠送数量', minWidth: 150 },
  { sortable: true, prop: 'defaultUnit', label: '基本单位', minWidth: 120 },
]
export const supplierTotalColumns: ColumnProps<Procure.ProcureWarehouseTotalDetail>[] = [
  {
    type: 'index',
    label: '序号',
    width: 60,
    search: {
      el: 'date-picker',
      label: '业务日期',
      key: 'date',
      order: 1,
      defaultValue: [formatDate(-getLastQuarterDays(), 'start', 'yyyy-MM-dd'), formatDate(0, 'end', 'yyyy-MM-dd')],
      props: {
        type: 'datetimerange',
        format: 'YYYY-MM-DD',
        valueFormat: 'YYYY-MM-DD',
      },
    },
  },
  { sortable: true, prop: 'supplierCode', label: '供应商代码', minWidth: 120 },
  {
    sortable: true,
    prop: 'supplierName',
    label: '供应商',
    minWidth: 120,
    enum: () => getSupplierAPI({ pageNum: 1, pageSize: 9999 }),
    fieldNames: { label: 'name', value: 'id' },
    isFilterEnum: false,
    search: { el: 'select', key: 'supplierId' },
  },
  { sortable: true, prop: 'deliveryQuantity', label: '收货数量', minWidth: 120 },
  { sortable: true, prop: 'deliveryAmount', label: '收货金额', minWidth: 120 },
  { sortable: true, prop: 'giftDeliveryQuantity', label: '收货赠送数量', minWidth: 150 },
  { sortable: true, prop: 'returnQuantity', label: '退货数量', minWidth: 120 },
  { sortable: true, prop: 'returnAmount', label: '退货金额', minWidth: 120 },
  { sortable: true, prop: 'giftReturnQuantity', label: '退货赠送数量', minWidth: 150 },
]
export const procureTypeTotalColumns: ColumnProps<Procure.ProcureWarehouseTotalDetail>[] = [
  {
    type: 'index',
    label: '序号',
    width: 60,
    search: {
      el: 'date-picker',
      label: '业务日期',
      key: 'date',
      order: 1,
      defaultValue: [formatDate(-getLastQuarterDays(), 'start', 'yyyy-MM-dd'), formatDate(0, 'end', 'yyyy-MM-dd')],
      props: {
        type: 'datetimerange',
        format: 'YYYY-MM-DD',
        valueFormat: 'YYYY-MM-DD',
      },
    },
  },
  // { sortable: true, prop: 'categoryCode', label: '类别代码', minWidth: 120 },
  { sortable: true, prop: 'categoryName', label: '类别名称', minWidth: 180 },
  { sortable: true, prop: 'deliveryQuantity', label: '收货数量', minWidth: 120 },
  { sortable: true, prop: 'deliveryAmount', label: '收货金额', minWidth: 120 },
  { sortable: true, prop: 'giftDeliveryQuantity', label: '收货赠送数量', minWidth: 150 },
  { sortable: true, prop: 'returnQuantity', label: '退货数量', minWidth: 120 },
  { sortable: true, prop: 'returnAmount', label: '退货金额', minWidth: 120 },
  { sortable: true, prop: 'giftReturnQuantity', label: '退货赠送数量', minWidth: 150 },
]
export const supplierGoodsTotalColumns: ColumnProps<Procure.ProcureWarehouseTotalDetail>[] = [
  {
    type: 'index',
    label: '序号',
    width: 60,
    search: {
      el: 'date-picker',
      label: '业务日期',
      key: 'date',
      order: 1,
      defaultValue: [formatDate(-getLastQuarterDays(), 'start', 'yyyy-MM-dd'), formatDate(0, 'end', 'yyyy-MM-dd')],
      props: {
        type: 'datetimerange',
        format: 'YYYY-MM-DD',
        valueFormat: 'YYYY-MM-DD',
      },
    },
  },
  { sortable: true, prop: 'supplierCode', label: '供应商代码', minWidth: 120 },
  {
    sortable: true,
    prop: 'supplierName',
    label: '供应商',
    minWidth: 120,
    enum: () => getSupplierAPI({ pageNum: 1, pageSize: 9999 }),
    fieldNames: { label: 'name', value: 'id' },
    isFilterEnum: false,
    search: { el: 'select', key: 'supplierId' },
  },
  { sortable: true, prop: 'sn', label: '商品代码', minWidth: 120 },
  { sortable: true, prop: 'goodsName', label: '商品名称', minWidth: 180 },
  { sortable: true, prop: 'barcode', label: '商品条码', minWidth: 180 },
  { sortable: true, prop: 'deliveryQuantity', label: '收货数量', minWidth: 120 },
  { sortable: true, prop: 'deliveryAmount', label: '收货金额', minWidth: 120 },
  { sortable: true, prop: 'giftDeliveryQuantity', label: '收货赠送数量', minWidth: 150 },
  { sortable: true, prop: 'returnQuantity', label: '退货数量', minWidth: 120 },
  { sortable: true, prop: 'returnAmount', label: '退货金额', minWidth: 120 },
  { sortable: true, prop: 'giftReturnQuantity', label: '退货赠送数量', minWidth: 150 },
]
export const supplierTypeTotalColumns: ColumnProps<Procure.ProcureWarehouseTotalDetail>[] = [
  {
    type: 'index',
    label: '序号',
    width: 60,
    search: {
      el: 'date-picker',
      label: '业务日期',
      key: 'date',
      order: 1,
      defaultValue: [formatDate(-getLastQuarterDays(), 'start', 'yyyy-MM-dd'), formatDate(0, 'end', 'yyyy-MM-dd')],
      props: {
        type: 'datetimerange',
        format: 'YYYY-MM-DD',
        valueFormat: 'YYYY-MM-DD',
      },
    },
  },
  { sortable: true, prop: 'supplierCode', label: '供应商代码', minWidth: 120 },
  {
    sortable: true,
    prop: 'supplierName',
    label: '供应商',
    minWidth: 120,
    enum: () => getSupplierAPI({ pageNum: 1, pageSize: 9999 }),
    fieldNames: { label: 'name', value: 'id' },
    isFilterEnum: false,
    search: { el: 'select', key: 'supplierId' },
  },
  // { sortable: true, prop: 'supplierType', label: '供应商类型', minWidth: 120 },
  // { sortable: true, prop: 'categoryCode', label: '类别代码', minWidth: 120 },
  { sortable: true, prop: 'categoryName', label: '类别名称', minWidth: 180 },
  { sortable: true, prop: 'deliveryQuantity', label: '收货数量', minWidth: 120 },
  { sortable: true, prop: 'deliveryAmount', label: '收货金额', minWidth: 120 },
  { sortable: true, prop: 'giftDeliveryQuantity', label: '收货赠送数量', minWidth: 150 },
  { sortable: true, prop: 'returnQuantity', label: '退货数量', minWidth: 120 },
  { sortable: true, prop: 'returnAmount', label: '退货金额', minWidth: 120 },
  { sortable: true, prop: 'giftReturnQuantity', label: '退货赠送数量', minWidth: 150 },
]
